package ud13.ventanas11JButtonIcon;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.util.Scanner;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class Main extends JFrame {
	int tAncho;
	int tAlto;
	private JPanel p;
	private JPanel p1;
	
	private void inicializar() {
		int anchoPantalla=Toolkit.getDefaultToolkit().getScreenSize().width;
		int altoPantalla=Toolkit.getDefaultToolkit().getScreenSize().height;
		tAncho=200;
		tAlto=200;
		setLayout(new GridLayout(1,1));
		setSize(tAncho, tAlto);
		setLocation(anchoPantalla/2-tAncho/2, altoPantalla/2-tAlto/2);
		setTitle("Ejercicio 04");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		//Creacion del panel principal.
		this.p = new JPanel();
		p.setLayout(new GridLayout(2,1));
		this.add(p);
		
		//Creacion JButton
		JButton b = new JButton("Pulsar");
		p.add(b);
		
		//Creacion JButton
		Icon i = new ImageIcon("c:/tmp/p.jpg");
		JButton b2 = new JButton(i);
		p.add(b2);
		
		
		setVisible(true);
		

	}
	
	public Main() {
		inicializar();
	}
	
	@SuppressWarnings("unused")
	private void mover() {
		int x = this.getLocation().x;
		int y = this.getLocation().y;
		
		for (int i = 0; i<200; i++) {
			setLocation(x+i, y);
			setSize(100+i, 400);
		}
	}

	public static void main(String[] args) {
		new Main();
	}

	private static String leerMensaje() {
		String mensaje="";
		Scanner scan = new Scanner(System.in);
		mensaje=scan.nextLine();
		scan.close();
		return mensaje;
	}
	
}
